(function($) {
	$.fn.progressDialog = function() {

	};

	$.fn.progressDialog.showDialog = function(text) {
		text = text || "Loading,Please wait..."
		createElement(text);
		setPosition();
		waterfall.appendTo("body");
		$(window).bind('resize', function() {
			setPosition();
		});
	}

	$.fn.progressDialog.hideDialog = function() {
		waterfall.remove();
	}

	function createElement(text) {
		if (!waterfall) {
			waterfall = $(document.createElement("div"));
			waterfall.attr("id", "waterfall");
			waterfall.css( {
				"height" : "345px",
				"width" : "310px",
				"filter" : "alpha(opacity = 50)",
				"-moz-opacity" : "0.5",
				"opacity" : "0.5",
				"background-color" : "#cccccc",
				"position" : "absolute",
				"left" : "1485px",
				"top" : "579px"
			});
		}
		if (!loadDiv) {
			loadDiv = document.createElement("div");
		}
		$(loadDiv).appendTo(waterfall);
		
//		var content = " <div style='width:" +width+ "px; height:" +Height+ "px;'><div style='height:30px; line-height:31px;padding-left:115px;font-weight:bolder;'>"+text+"</div><div align='center'><img src='images/loading.gif' border='0'/></div></div>";
        var content = "<div align='center'><p style='font-size: 18px;font-weight: bolder;position: absolute;padding-top: 10px;padding-left: 107px;'>"+text+"</p><img src='images/loading.gif' border='0'/></div>";
        $(loadDiv).html(content);
	}

	function setPosition() {
		var leftOffset =20;
		var topOffset = 140;
		$(loadDiv).css( {
			"position" : "absolute",
			"height" : Height + "px",
			"width" : width + "px",
			"left" : leftOffset + "px",
			"top" : topOffset + "px"
		});
	}

	var waterfall;
	var loadDiv;
	var width = 245;
	var Height = 295;
})(jQuery);